package com.ruoyi.project.kkad.goodsad.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.framework.aspectj.lang.annotation.DataSource;
import com.ruoyi.framework.aspectj.lang.enums.DataSourceType;
import com.ruoyi.project.kkad.goodsad.domain.GoodsAd;
import com.ruoyi.project.kkad.goodsad.mapper.GoodsAdMapper;
import com.ruoyi.project.kkad.goodsad.service.IGoodsAdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 商品广告Service业务层处理
 *
 * @author shixiangwen
 * @date 2021-08-06
 */
@Service
@DataSource(DataSourceType.KKAD)
public class GoodsAdServiceImpl implements IGoodsAdService {

    @Autowired
    private GoodsAdMapper goodsAdMapper;

    /**
     * 查询商品广告
     *
     * @param id 商品广告ID
     * @return 商品广告
     */
    @Override
    public GoodsAd selectGoodsAdById(Long id) {
        return goodsAdMapper.selectGoodsAdById(id);
    }

    /**
     * 查询商品广告列表
     *
     * @param goodsAd 商品广告
     * @return 商品广告
     */
    @Override
    public List<GoodsAd> selectGoodsAdList(GoodsAd goodsAd) {
        return goodsAdMapper.selectGoodsAdList(goodsAd);
    }

    /**
     * 新增商品广告
     *
     * @param goodsAd 商品广告
     * @return 结果
     */
    @Override
    public int insertGoodsAd(GoodsAd goodsAd) {
        goodsAd.setCreatedTime(DateUtils.getNowDate());
        return goodsAdMapper.insertGoodsAd(goodsAd);
    }

    /**
     * 修改商品广告
     *
     * @param goodsAd 商品广告
     * @return 结果
     */
    @Override
    public int updateGoodsAd(GoodsAd goodsAd) {
        return goodsAdMapper.updateGoodsAd(goodsAd);
    }

    /**
     * 删除商品广告对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteGoodsAdByIds(String ids) {
        return goodsAdMapper.deleteGoodsAdByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除商品广告信息
     *
     * @param id 商品广告ID
     * @return 结果
     */
    @Override
    public int deleteGoodsAdById(Long id) {
        return goodsAdMapper.deleteGoodsAdById(id);
    }
}
